﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DistributedGraph;

namespace CAP.Forms
{
    /// <summary>
    /// Allgemeine Klasse zur Darstellung von Animationen. (im NodeGraph)
    /// </summary>
    class NodeGraphAnimation
    {
        #region Attribute
        private DateTime startTime;
        private DateTime endTime;
        private double duration;
        #endregion Attribute

        #region Eigenschaften
        /// <summary>
        /// Gibt an ob die Animation beendet wurde.
        /// </summary>
        public bool IsDone { get { return DateTime.Now.Ticks > endTime.Ticks; } }

        /// <summary>
        /// Gibt den Fortschritt der Animation an. (0 - 1)
        /// </summary>
        public double Progress { get { return Math.Min(1, (new TimeSpan(DateTime.Now.Ticks - startTime.Ticks)).TotalMilliseconds / duration); } }
        #endregion Eigenschaften

        #region Methoden
        /// <summary>
        /// Instanziiert und initialisiert die Klasse.
        /// </summary>
        /// <param name="duration">Die Dauer der Animation (in Milisekunden)</param>
        public NodeGraphAnimation(double duration)
        {
            this.duration = duration;
            this.startTime = DateTime.Now;
            this.endTime = this.startTime.AddMilliseconds(duration);
        }
        #endregion Methoden
    }
}
